/* API配置管理器样式 */

/* 确保在所有主题下的可见性 */
.api_config_settings *,
#api-config-manager * {
    box-sizing: border-box;
}

/* 头部样式 */
.api-config-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-right: 10px;
}

.api-config-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.api-config-version {
    font-size: 0.8em;
    opacity: 0.7;
    font-weight: normal;
    background: rgba(0, 123, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--SmartThemeEmColor, #007bff);
}

.api-config-actions {
    display: flex;
    gap: 5px;
}

.api-config-update-btn {
    background: #17a2b8 !important;
    color: white !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    min-width: 32px;
    height: 24px;
    border-radius: 3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

.api-config-update-btn:hover {
    background: #138496 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.api-config-update-btn.update-available {
    background: #28a745 !important;
    animation: api-config-pulse 2s infinite;
}

.api-config-update-btn.update-available:hover {
    background: #218838 !important;
}

@keyframes api-config-pulse {
    0% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(40, 167, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(40, 167, 69, 0); }
}

/* 按钮容器样式 - 确保横向布局 */
.api_config_settings .button-container {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: center !important;
    flex-wrap: nowrap !important;
}

/* 模型输入容器样式 */
.api_config_settings .model-input-container {
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    align-items: center !important;
}

/* 保存按钮样式 */
#api-config-save {
    flex: 1 !important;
    min-width: 100px !important;
    white-space: nowrap !important;
}

/* 取消按钮样式 */
#api-config-cancel {
    background-color: #dc3545 !important;
    color: white !important;
    border: none !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    white-space: nowrap !important;
    min-width: 70px !important;
    max-width: 80px !important;
    flex-shrink: 0 !important;
    height: auto !important;
    line-height: 1.2 !important;
}

#api-config-cancel:hover {
    background-color: #c82333 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px) !important;
}

/* 强制按钮在白色主题下可见 */
.api_config_settings .menu_button,
#api-config-manager .menu_button {
    position: relative;
    z-index: 1;
    transition: all 0.2s ease;
}

/* 白色主题适配 */
@media (prefers-color-scheme: light),
body[data-theme="white"],
body.white-theme,
.white-theme {
    .api-config-apply {
        background: #28a745 !important;
        border: 1px solid #1e7e34 !important;
    }

    .api-config-apply:hover {
        background: #218838 !important;
        border: 1px solid #1c7430 !important;
    }

    #api-config-save {
        background: #28a745 !important;
        border: 1px solid #1e7e34 !important;
    }

    #api-config-save:hover {
        background: #218838 !important;
        border: 1px solid #1c7430 !important;
    }

    .api-config-item {
        border: 1px solid #dee2e6 !important;
        background: #f8f9fa !important;
    }

    .api-config-name {
        color: #212529 !important;
    }
}

.api_config_settings {
    border: 1px solid var(--SmartThemeBorderColor);
    border-radius: 5px;
    margin: 15px 0;
    background: var(--SmartThemeBodyColor);
}

/* 当在API连接界面时的特殊样式 */
#openai_api .api_config_settings,
#custom_form + .api_config_settings {
    margin-top: 20px;
    border-color: var(--SmartThemeEmColor);
    background: var(--SmartThemeBlurTintColor);
}

#api-config-manager {
    border: 1px solid var(--SmartThemeBorderColor);
    border-radius: 5px;
    margin: 5px 0;
    background: var(--SmartThemeBodyColor);
}

#api-config-content {
    padding: 10px;
    border-top: 1px solid var(--SmartThemeBorderColor);
}

.api-config-section {
    margin-bottom: 15px;
}

.api-config-section h4 {
    margin: 0 0 8px 0;
    color: var(--SmartThemeEmColor);
    font-size: 14px;
}

.api-config-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    border: 1px solid var(--SmartThemeBorderColor);
    border-radius: 6px;
    background: var(--SmartThemeBlurTintColor, rgba(255, 255, 255, 0.9));
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.api-config-info {
    flex: 1;
    min-width: 0;
}

.api-config-name {
    font-weight: bold;
    color: var(--SmartThemeEmColor, #333);
    margin-bottom: 4px;
    font-size: 14px;
}

.api-config-model {
    font-size: 12px;
    color: var(--SmartThemeEmColor, #007bff);
    font-weight: 500;
    background: rgba(0, 123, 255, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.api-config-no-model {
    font-size: 12px;
    color: var(--grey70, #999);
    font-style: italic;
    opacity: 0.7;
}

.api-config-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.api-config-apply {
    background: var(--SmartThemeCheckboxBgColor, #28a745) !important;
    color: white !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    min-width: 50px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.api-config-apply:hover {
    background: var(--SmartThemeCheckboxBgColorHover, #218838) !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.api-config-delete {
    background: #dc3545 !important;
    color: white !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    min-width: 50px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.api-config-delete:hover {
    background: #c82333 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.api-config-edit {
    background: #17a2b8 !important;
    color: white !important;
    border: none !important;
    padding: 4px 8px !important;
    font-size: 12px !important;
    min-width: 50px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.api-config-edit:hover {
    background: #138496 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.api-config-empty {
    text-align: center;
    color: var(--SmartThemeQuoteColor);
    opacity: 0.7;
    padding: 20px;
    font-style: italic;
}

#api-config-name,
#api-config-url,
#api-config-key,
#api-config-model {
    margin-bottom: 5px;
}

#api-config-save {
    background: var(--SmartThemeCheckboxBgColor, #28a745) !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#api-config-save:hover {
    background: var(--SmartThemeCheckboxBgColorHover, #218838) !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#api-config-fetch-models {
    background: #6c757d !important;
    color: white !important;
    border: none !important;
    padding: 6px 12px !important;
    white-space: nowrap;
    font-size: 12px !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

#api-config-fetch-models:hover {
    background: #5a6268 !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

#api-config-model-select {
    margin-bottom: 5px;
    background: var(--SmartThemeBlurTintColor);
    color: var(--SmartThemeEmColor);
    border: 1px solid var(--SmartThemeBorderColor);
}

/* 响应式设计 */

/* 大屏幕 (桌面) */
@media (min-width: 1200px) {
    #api-config-content {
        padding: 15px;
    }

    .api-config-item {
        padding: 15px;
    }

    .api-config-actions {
        gap: 8px;
    }

    .api-config-actions .menu_button {
        padding: 6px 15px;
        font-size: 13px;
        min-width: 70px;
    }
}

/* 中等屏幕 (平板) */
@media (max-width: 1199px) and (min-width: 769px) {
    .api-config-item {
        padding: 12px;
    }

    .api-config-actions {
        gap: 6px;
    }

    .api-config-actions .menu_button {
        padding: 5px 12px;
        font-size: 12px;
        min-width: 60px;
    }
}

/* 小屏幕 (手机横屏) */
@media (max-width: 768px) and (min-width: 481px) {
    .api-config-item {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
    }

    .api-config-actions {
        margin-top: 10px;
        justify-content: center;
        gap: 8px;
    }

    .api-config-actions .menu_button {
        flex: 1;
        max-width: 100px;
        padding: 8px 12px;
        font-size: 12px;
    }

    .api-config-name {
        font-size: 13px;
    }

    .api-config-model,
    .api-config-no-model {
        font-size: 11px;
    }
}

/* 超小屏幕 (手机竖屏) */
@media (max-width: 480px) {
    #api-config-content {
        padding: 8px;
    }

    .api-config-item {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        margin: 8px 0;
        min-height: auto;
    }

    .api-config-info {
        margin-bottom: 12px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    .api-config-name {
        font-size: 14px;
        margin-bottom: 8px;
        line-height: 1.4;
        word-wrap: break-word;
    }

    .api-config-model,
    .api-config-no-model {
        font-size: 12px;
        line-height: 1.3;
        word-wrap: break-word;
    }

    .api-config-model {
        padding: 3px 6px;
        display: inline-block;
        max-width: 100%;
        box-sizing: border-box;
    }

    .api-config-actions {
        display: flex;
        flex-direction: row;
        gap: 8px;
        justify-content: space-between;
    }

    .api-config-actions .menu_button {
        flex: 1;
        padding: 12px 8px;
        font-size: 12px;
        text-align: center;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* 表单元素在小屏幕上的优化 */
    .api-config-section .text_pole {
        font-size: 14px;
        padding: 10px;
    }

    .api-config-section .menu_button {
        padding: 12px;
        font-size: 14px;
    }

    /* 获取模型按钮在小屏幕上的处理 - 只影响模型输入容器 */
    .api_config_settings .model-input-container {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* 保存和取消按钮容器在小屏幕上仍保持横向布局 */
    .api_config_settings .button-container {
        flex-direction: row !important;
        gap: 8px !important;
        justify-content: flex-start !important;
    }

    #api-config-fetch-models {
        width: 100%;
        padding: 12px;
        font-size: 14px;
    }
}
